﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Blogs01
{
    class DbHelper
    {
        public static readonly string conString = "server =BF-202003151143\\SQLEXPRESS; database = Blogs; uid = sa; pwd = 3578520hr";

        //获取列表
        public static DataTable GetDataTable(string sql)
        {

            SqlConnection Connection = new SqlConnection(conString);
            SqlDataAdapter Datadapter = new SqlDataAdapter(sql, Connection);
            DataTable dt = new DataTable();
            Connection.Open();
            Datadapter.Fill(dt);
            return dt;
        }

        //添加引用
        public static int Addddd(string sql)
        {
            SqlConnection connection = new SqlConnection(conString);
            SqlCommand command = new SqlCommand(sql, connection);
            connection.Open();
            return command.ExecuteNonQuery();
        }

    }
}
